# -*- coding: utf-8 -*-

"""
    @author: Luis Fonte n6043
    @date: 10/06/2013
    @obs: Code created on class from documentation given by teacher
"""

class Bubble():
    '''
    Class Bubble
    Class with a bubble sort algorithm implemented on function bubblesort
    '''
    
    
    def __init__(self, A):
        """
        Constructor of class
        @param A - list with numbers desordered
        """
        self.A = A  #list received by parameter
        pass

    
    def bubblesort(self):
        """
        Function bubblesort
        Ordinates a list - Lesser values to greater values
        Compares and ordinates 2 values by iteration
        """
        for i in xrange (0, len(self.A)):
            for j in xrange (len(self.A)-1,i, -1):
                if self.A[j] < self.A[j-1]:     #compares 2 values
                    self.A[j], self.A[j-1] = self.A[j-1], self.A[j] #if second value > first value, changes its positions in list
                    pass
                pass
            pass
        pass


